﻿@using Abp.Collections.Extensions
@using PithyDesign.Web.Views.Shared.Components.TopMenu
@model TopMenuViewModel
@{
    //TODO: Get current virtual path
    var ApplicationPath = "/";
}
@foreach (var menuItem in Model.MainMenu.Items)
{
<li class="layui-nav-item @(Model.ActiveMenuItemName == menuItem.Name ? "active" : "")">
    @if (menuItem.Items.IsNullOrEmpty())
    {
        <!--只有一级菜单-->
        <a href="@Model.CalculateMenuUrl(ApplicationPath, menuItem)">
            @if (!string.IsNullOrWhiteSpace(menuItem.Icon))
            {
                <i class="@menuItem.Icon"></i>
            }
            @menuItem.DisplayName
        </a>
    }
    else
    {
        <!--存在二级菜单-->
        <a href="javascript:;">
            @if (!string.IsNullOrWhiteSpace(menuItem.Icon))
            {
                <i class="@menuItem.Icon"></i>
            }
            @menuItem.DisplayName
        </a>
        <dl class="layui-nav-child">
            @foreach (var subMenuItem in menuItem.Items)
            {
                <dd>
                    <a href="@Model.CalculateMenuUrl(ApplicationPath, subMenuItem)">
                        @if (!string.IsNullOrWhiteSpace(subMenuItem.Icon))
                        {
                            <i class="@subMenuItem.Icon"></i>
                        }
                        @subMenuItem.DisplayName
                    </a>
                </dd>
            }
        </dl>
    }
</li>
}